package org.qqcui.designpattern.patterns.command;

/**
 * 命令模式客户端
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022/5/6 11:23
 **/
public class Client {

    public static void main(String[] args) {
        // 构造电灯开关命令
        LightReceiver lightReceiver = new LightReceiver();
        LightOnCommand lightOnCommand = new LightOnCommand(lightReceiver);
        LightOffCommand lightOffCommand = new LightOffCommand(lightReceiver);

        // 构造远程控制对象
        RemoteController remoteController = new RemoteController();
        // 设置为第0组开关
        remoteController.setCommands(0, lightOnCommand, lightOffCommand);
        System.out.println("==============按下电灯的开启按钮===============");
        remoteController.onButtonWasPushed(0);
        System.out.println("==============按下电灯的关闭按钮===============");
        remoteController.offButtonWasPushed(0);
        System.out.println("===============按下撤销按钮================");
        remoteController.undoButtonWasPushed();
    }
}
